package com.example.demo.controller.app;

import com.example.demo.service.app.AppService;
import com.example.demo.vo.app.AppVO;
import com.example.demo.vo.ResultVO;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/app")
public class AppController {
    @Resource
    AppService appService;


    @PostMapping("/uploadApp")
    public ResultVO<AppVO> uploadApp(@RequestParam("file") MultipartFile app,@RequestParam("username") String username) {
        return appService.uploadApp(app, username);
    }

    @GetMapping("/getAppByEmployer")
    public ResultVO<List<AppVO>> getAppByEmployer(@RequestParam String username,@RequestParam("pageNum") int pageNum) {
        return appService.getAppByEmployer(username,pageNum);
    }
    @GetMapping("/download/{originName:.+}")
    public void download(@PathVariable String originName, @RequestParam String newName, HttpServletResponse response) {
        appService.downloadFile(originName, newName, response);
    }
}
